<style>
	.label1 {
		display: block;
		float:left;
		width:25%;
		text-align:left;		
	}
	datalist {
		height:6em;
		overflow:scroll;
	}
</style>
<div class="form-group">
	<label class="col-xs-12 col-sm-3 col-md-2 control-label">优惠卷组{$goods['couponsid']}</label>
	<div class="col-sm-9 col-xs-12">
		{loop $couponlist $item}
			<label class="label1"><input class="check" type="checkbox" name="functions" value="{$item['id']}" onclick="chk()" {if strpos($goods['couponsids'], $item['id']) !== false}checked{/if}>{$item['name']}</label>
		{/loop}
		<input type="text" name="functionValue" id="functionValue" style="display:none;"/>
	</div>
</div>
<div class="form-group">
	<label class="col-xs-12 col-sm-3 col-md-2 control-label">抽奖规则</label>
	<div class="col-sm-9 col-xs-12">
		{php echo tpl_ueditor('goods[luckcontent]', $goods['luckcontent']);}
	</div>
</div>
<script>
function chk(){ 
var obj=document.getElementsByName('functions'); //选择所有name="'test'"的对象，返回数组 
//取到对象数组后，我们来循环检测它是不是被选中 
var s=''; 
for(var i=0; i<obj.length; i++){ 
if(obj[i].checked) s+=obj[i].value+','; //如果选中，将value添加到变量s中 
} 
//那么现在来检测s的值就知道选中的复选框的值了 
//alert(s==''?'你还没有选择任何内容！':s); 
document.getElementById('functionValue').value=s.slice(0,-1);

} 


function functionValues() {
var functionValue = document.getElementById("functionValue");
		  var len = check.length;
		  var str = '';
		  for (var i = 0; i < len; i++) {
			if (check[i].checked){
				str += check[i].value +',';
			}
		  }
		  functionValue.value = str.slice(0,-1);
		}
</script>